package com.zenithmind.chat.pojo.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;

/**
 * 群组关联DTO - 遵循单一职责原则
 * 只负责群组关联的数据传输
 * 
 * @author ZenithMind Team
 * @since 2025-01-09
 */
@Data
@Schema(description = "群组关联DTO")
public class ChatGroupAssociationDTO {

    @Schema(description = "群组ID")
    @NotBlank(message = "群组ID不能为空")
    private String groupId;

    @Schema(description = "关联类型")
    @NotBlank(message = "关联类型不能为空")
    private String associationType;

    @Schema(description = "关联资源ID")
    @NotBlank(message = "关联资源ID不能为空")
    private String resourceId;

    @Schema(description = "关联资源名称")
    @Size(max = 100, message = "关联资源名称长度不能超过100个字符")
    private String resourceName;

    @Schema(description = "关联资源描述")
    @Size(max = 500, message = "关联资源描述长度不能超过500个字符")
    private String resourceDescription;

    @Schema(description = "扩展信息")
    private String extraInfo;

    @Schema(description = "排序")
    private Integer sortOrder;

    @Schema(description = "是否启用")
    private Boolean enabled;

    /**
     * 验证DTO数据
     *
     * @return 验证结果
     */
    public boolean isValid() {
        return groupId != null && !groupId.trim().isEmpty() &&
               associationType != null && !associationType.trim().isEmpty() &&
               resourceId != null && !resourceId.trim().isEmpty();
    }

    /**
     * 获取显示名称
     *
     * @return 显示名称
     */
    public String getDisplayName() {
        if (resourceName != null && !resourceName.trim().isEmpty()) {
            return resourceName;
        }
        return associationType + ":" + resourceId;
    }
}
